<!DOCTYPE html>





<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 3.9.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png?v=7.4.0">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32.png?v=7.4.0">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16.png?v=7.4.0">
  <link rel="mask-icon" href="/images/avatar.svg?v=7.4.0" color="#222">
  <link rel="alternate" href="/atom.xml" title="Anemone's Blog" type="application/atom+xml">
  <meta name="google-site-verification" content="Re5JdegRYzNFco-rC9lYIsvSWIgh5JvyfhuEaZCeFCk">
  <meta name="baidu-site-verification" content="opTC8YN3Pn">

<link rel="stylesheet" href="/css/main.css?v=7.4.0">


<link rel="stylesheet" href="https://cdn.bootcss.com/font-awesome/4.7.0/css/font-awesome.min.css">


<script id="hexo-configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/',
    scheme: 'Pisces',
    version: '7.4.0',
    exturl: false,
    sidebar: {"position":"left","display":"post","offset":12,"onmobile":false},
    copycode: {"enable":false,"show_result":false,"style":null},
    back2top: {"enable":true,"sidebar":false,"scrollpercent":false},
    bookmark: {"enable":false,"color":"#222","save":"auto"},
    fancybox: false,
    mediumzoom: false,
    lazyload: false,
    pangu: false,
    algolia: {
      appID: 'GB90MXPJ1C',
      apiKey: '05d808da3baf50ac2f2fad2dc3a3cd8f',
      indexName: 'dev_blog',
      hits: {"per_page":20},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    },
    localsearch: {"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":true,"preload":false},
    path: 'search.xml',
    motion: {"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},
    translation: {
      copy_button: '复制',
      copy_success: '复制成功',
      copy_failure: '复制失败'
    },
    sidebarPadding: 40
  };
</script>

  <meta name="description" content="2018年网鼎杯，emmm，好不容易看到个算法题还花了很长时间，太难过了T_T二叉树0x01下载题目后，得到一张红黑树的图片和README.txt. 将readme进行base64解码可以得到hit：1234561.这是一棵红黑树2.树从1-59上的果子依次为 ek`~3c:gf017b744/b38fd~abm7g5489e2&amp;#123;lf6z8d16hae`98&amp;#125;b|-21m.e:">
<meta name="keywords" content="CTF,二叉树,符号执行,angr">
<meta property="og:type" content="article">
<meta property="og:title" content="2018网鼎杯二叉树&amp;martricks wp">
<meta property="og:url" content="http://anemone.top/ctf-2018网鼎杯二叉树-martrickswp/index.html">
<meta property="og:site_name" content="Anemone&#39;s Blog">
<meta property="og:description" content="2018年网鼎杯，emmm，好不容易看到个算法题还花了很长时间，太难过了T_T二叉树0x01下载题目后，得到一张红黑树的图片和README.txt. 将readme进行base64解码可以得到hit：1234561.这是一棵红黑树2.树从1-59上的果子依次为 ek`~3c:gf017b744/b38fd~abm7g5489e2&amp;#123;lf6z8d16hae`98&amp;#125;b|-21m.e:">
<meta property="og:locale" content="zh-CN">
<meta property="og:image" content="http://anemone.top/ctf-2018网鼎杯二叉树-martrickswp/1535025943800.png">
<meta property="og:updated_time" content="2019-09-22T10:14:18.636Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="2018网鼎杯二叉树&amp;martricks wp">
<meta name="twitter:description" content="2018年网鼎杯，emmm，好不容易看到个算法题还花了很长时间，太难过了T_T二叉树0x01下载题目后，得到一张红黑树的图片和README.txt. 将readme进行base64解码可以得到hit：1234561.这是一棵红黑树2.树从1-59上的果子依次为 ek`~3c:gf017b744/b38fd~abm7g5489e2&amp;#123;lf6z8d16hae`98&amp;#125;b|-21m.e:">
<meta name="twitter:image" content="http://anemone.top/ctf-2018网鼎杯二叉树-martrickswp/1535025943800.png">
  <link rel="canonical" href="http://anemone.top/ctf-2018网鼎杯二叉树-martrickswp/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome: false,
    isPost: true,
    isPage: false,
    isArchive: false
  };
</script>

  <title>2018网鼎杯二叉树&martricks wp | Anemone's Blog</title>
  








  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .logo,
  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

</head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-CN">
  <div class="container use-motion">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-meta">

    <div>
      <a href="/" class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Anemone's Blog</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
  </div>

  <div class="site-nav-toggle">
    <button aria-label="切换导航栏">
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>


<nav class="site-nav">
  
  <ul id="menu" class="menu">
      
      
      
        
        <li class="menu-item menu-item-home">
      
    

    <a href="/" rel="section"><i class="fa fa-fw fa-home"></i>首页</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-about">
      
    

    <a href="/about/" rel="section"><i class="fa fa-fw fa-user"></i>关于</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-tags">
      
    

    <a href="/tags/" rel="section"><i class="fa fa-fw fa-tags"></i>标签</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-categories">
      
    

    <a href="/categories/" rel="section"><i class="fa fa-fw fa-th"></i>分类</a>

  </li>
      
      
      
        
        <li class="menu-item menu-item-archives">
      
    

    <a href="/archives/" rel="section"><i class="fa fa-fw fa-archive"></i>归档</a>

  </li>
      <li class="menu-item menu-item-search">
        <a href="javascript:;" class="popup-trigger">
        
          <i class="fa fa-search fa-fw"></i>搜索</a>
      </li>
    
  </ul>

</nav>
  <div class="site-search">
    <div class="popup search-popup">
    <div class="search-header">
  <span class="search-icon">
    <i class="fa fa-search"></i>
  </span>
  <div class="search-input" id="search-input"></div>
  <span class="popup-btn-close">
    <i class="fa fa-times-circle"></i>
  </span>
</div>
<div class="algolia-results">
  <div id="algolia-stats"></div>
  <div id="algolia-hits"></div>
  <div id="algolia-pagination" class="algolia-pagination"></div>
</div>

  
</div>
<div class="search-pop-overlay"></div>

  </div>
</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>


    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
            

          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
      <article itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block post">
    <link itemprop="mainEntityOfPage" href="http://anemone.top/ctf-2018网鼎杯二叉树-martrickswp/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Anemone">
      <meta itemprop="description" content="关注Web安全、移动安全、Fuzz测试和机器学习">
      <meta itemprop="image" content="/images/avatar.jpg">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Anemone's Blog">
    </span>
      <header class="post-header">
        <h2 class="post-title" itemprop="name headline">2018网鼎杯二叉树&martricks wp

          
        </h2>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              
                
              

              <time title="创建时间：2018-08-23 20:25:47" itemprop="dateCreated datePublished" datetime="2018-08-23T20:25:47+08:00">2018-08-23</time>
            </span>
          
            

            
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="fa fa-calendar-check-o"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2019-09-22 18:14:18" itemprop="dateModified" datetime="2019-09-22T18:14:18+08:00">2019-09-22</time>
              </span>
            
          
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="fa fa-folder-o"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
              
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing"><a href="/categories/CTF/" itemprop="url" rel="index"><span itemprop="name">CTF</span></a></span>

                
                
              
            </span>
          

          
            <span id="/ctf-2018网鼎杯二叉树-martrickswp/" class="post-meta-item leancloud_visitors" data-flag-title="2018网鼎杯二叉树&martricks wp" title="阅读次数">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span class="leancloud-visitors-count"></span>
            </span>
          

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <p>2018年网鼎杯，emmm，好不容易看到个算法题还花了很长时间，太难过了T_T</p><h1 id="二叉树"><a href="#二叉树" class="headerlink" title="二叉树"></a>二叉树</h1><h2 id="0x01"><a href="#0x01" class="headerlink" title="0x01"></a>0x01</h2><p>下载题目后，得到一张红黑树的图片和README.txt. 将readme进行base64解码可以得到hit：</p><figure class="highlight plain"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">1.这是一棵红黑树</span><br><span class="line">2.树从1-59上的果子依次为 ek`~3c:gf017b744/b38fd~abm7g5489e2&#123;lf6z8d16hae`98&#125;b|-21m.e:</span><br><span class="line">3.依次从树上取走第 18,35,53,50,14,28,19,6,54,36 个果子,过程中保持红黑树性质不变</span><br><span class="line">4.tmpflag为第 8,56,47,37,52,34,17,8,8,29,7,47,40,57,46,24,34,34,57,29,22,5,16,57,24,29,8,12,57,12,12,21,33,34,55,51,22,45,34,31,1,23 个果子</span><br><span class="line">5.flag为 tmpflag 红色果子 ASCII +1 , 黑色果子 ASCII-1</span><br><span class="line">6.让我们愉快的开始获取flag吧</span><br></pre></td></tr></table></figure><a id="more"></a>


<h2 id="0x02"><a href="#0x02" class="headerlink" title="0x02"></a>0x02</h2><p>经过提示，首先需要找一份红黑树的实现，并且按照图片构造一颗红黑树(如果不按图片会出现多解情况，因为这点被坑惨)，以下给出一个很好的python版红黑树实现</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br><span class="line">239</span><br><span class="line">240</span><br><span class="line">241</span><br><span class="line">242</span><br><span class="line">243</span><br><span class="line">244</span><br><span class="line">245</span><br><span class="line">246</span><br><span class="line">247</span><br><span class="line">248</span><br><span class="line">249</span><br><span class="line">250</span><br><span class="line">251</span><br><span class="line">252</span><br><span class="line">253</span><br><span class="line">254</span><br><span class="line">255</span><br><span class="line">256</span><br><span class="line">257</span><br><span class="line">258</span><br><span class="line">259</span><br><span class="line">260</span><br><span class="line">261</span><br><span class="line">262</span><br><span class="line">263</span><br><span class="line">264</span><br><span class="line">265</span><br><span class="line">266</span><br><span class="line">267</span><br><span class="line">268</span><br><span class="line">269</span><br><span class="line">270</span><br><span class="line">271</span><br><span class="line">272</span><br><span class="line">273</span><br><span class="line">274</span><br><span class="line">275</span><br><span class="line">276</span><br><span class="line">277</span><br><span class="line">278</span><br><span class="line">279</span><br><span class="line">280</span><br><span class="line">281</span><br><span class="line">282</span><br><span class="line">283</span><br><span class="line">284</span><br><span class="line">285</span><br><span class="line">286</span><br><span class="line">287</span><br><span class="line">288</span><br><span class="line">289</span><br><span class="line">290</span><br><span class="line">291</span><br><span class="line">292</span><br><span class="line">293</span><br><span class="line">294</span><br><span class="line">295</span><br><span class="line">296</span><br><span class="line">297</span><br><span class="line">298</span><br><span class="line">299</span><br><span class="line">300</span><br><span class="line">301</span><br><span class="line">302</span><br><span class="line">303</span><br><span class="line">304</span><br><span class="line">305</span><br><span class="line">306</span><br><span class="line">307</span><br><span class="line">308</span><br><span class="line">309</span><br><span class="line">310</span><br><span class="line">311</span><br><span class="line">312</span><br><span class="line">313</span><br><span class="line">314</span><br><span class="line">315</span><br><span class="line">316</span><br><span class="line">317</span><br><span class="line">318</span><br><span class="line">319</span><br><span class="line">320</span><br><span class="line">321</span><br><span class="line">322</span><br><span class="line">323</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment"># -*- coding: utf-8 -*-</span></span><br><span class="line">BLACK = <span class="number">0</span></span><br><span class="line">RED = <span class="number">1</span></span><br><span class="line"><span class="comment">#graphic elements of rbtree for printing</span></span><br><span class="line">VC = <span class="string">'│'</span></span><br><span class="line">HC = <span class="string">'─'</span></span><br><span class="line">SIZE = <span class="number">3</span></span><br><span class="line">RIG = <span class="string">'┌'</span> + HC * SIZE</span><br><span class="line">LEF = <span class="string">'└'</span> + HC * SIZE</span><br><span class="line">SP = chr(<span class="number">32</span>)</span><br><span class="line">IND1 = SP * (SIZE + <span class="number">1</span>)</span><br><span class="line">IND2 = VC + SP * SIZE</span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">rbnode</span><span class="params">(object)</span>:</span></span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">__init__</span><span class="params">(self, key=None, value=None, color=BLACK,left=None,right=None,p=None)</span>:</span></span><br><span class="line">        self.key = key</span><br><span class="line">        self.value = value</span><br><span class="line">        self.color = color</span><br><span class="line">        self.left = left</span><br><span class="line">        self.right = right</span><br><span class="line">        self.p = p</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">__repr__</span><span class="params">(self)</span>:</span></span><br><span class="line">        <span class="keyword">return</span> <span class="string">'%s%s%s'</span> % (self.key,<span class="string">'◆'</span> <span class="keyword">if</span> self.color <span class="keyword">is</span> BLACK <span class="keyword">else</span> <span class="string">'◇'</span>,self.value )</span><br><span class="line"></span><br><span class="line">_NONE=rbnode()</span><br><span class="line"></span><br><span class="line"><span class="class"><span class="keyword">class</span> <span class="title">rbtree</span><span class="params">(object)</span>:</span></span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">__init__</span><span class="params">(self, data=False,default_value=<span class="number">0</span>, nodes=None)</span>:</span></span><br><span class="line">        <span class="keyword">if</span> nodes:</span><br><span class="line">            self.root = nodes[<span class="number">28</span>]</span><br><span class="line">            self.default_value = default_value <span class="comment">#for method: force_search</span></span><br><span class="line">            self.nil = _NONE</span><br><span class="line">        <span class="keyword">else</span>:</span><br><span class="line">            self.nil = _NONE</span><br><span class="line">            self.root = self.nil</span><br><span class="line">            self.default_value = default_value <span class="comment">#for method: force_search</span></span><br><span class="line">            <span class="keyword">if</span> hasattr(data, <span class="string">'__iter__'</span>):</span><br><span class="line">                <span class="keyword">for</span> key, value <span class="keyword">in</span> data:</span><br><span class="line">                    self.insert(rbnode(key,value))</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">__repr__</span><span class="params">(self)</span>:</span></span><br><span class="line">        <span class="keyword">return</span> <span class="string">'\n'</span>.join(self.graph())</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">graph</span><span class="params">(self, x=False, prefix=<span class="string">''</span>)</span>:</span></span><br><span class="line">        <span class="string">"beautifully print rbtree, big key node first"</span></span><br><span class="line">        <span class="keyword">if</span> x <span class="keyword">is</span> <span class="literal">False</span>:</span><br><span class="line">            x = self.root</span><br><span class="line">        <span class="keyword">if</span> x <span class="keyword">is</span> <span class="keyword">not</span> self.nil:</span><br><span class="line">            p = x.p</span><br><span class="line">            last_prefix = <span class="string">''</span></span><br><span class="line">            <span class="keyword">if</span> p <span class="keyword">is</span> <span class="keyword">not</span> self.nil:</span><br><span class="line">                pp = p.p</span><br><span class="line">                last_prefix = LEF <span class="keyword">if</span> p.left <span class="keyword">is</span> x <span class="keyword">else</span> RIG</span><br><span class="line">                <span class="keyword">if</span> pp <span class="keyword">is</span> <span class="keyword">not</span> self.nil:</span><br><span class="line">                    <span class="keyword">if</span> (pp.left <span class="keyword">is</span> p) <span class="keyword">is</span> (p.left <span class="keyword">is</span> x):</span><br><span class="line">                        prefix = prefix + IND1</span><br><span class="line">                    <span class="keyword">else</span>:</span><br><span class="line">                        prefix = prefix + IND2</span><br><span class="line">            <span class="keyword">yield</span> <span class="keyword">from</span> self.graph(x.right, prefix)</span><br><span class="line">            <span class="keyword">yield</span> <span class="string">'%s%s%s'</span> % (prefix, last_prefix, x)</span><br><span class="line">            <span class="keyword">yield</span> <span class="keyword">from</span> self.graph(x.left, prefix)</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">search</span><span class="params">(self, key, x=False)</span>:</span></span><br><span class="line">        <span class="string">"find node according to key, return self.nil if not found"</span></span><br><span class="line">        <span class="keyword">if</span> x <span class="keyword">is</span> <span class="literal">False</span>:</span><br><span class="line">            x = self.root</span><br><span class="line">        <span class="keyword">while</span> (x <span class="keyword">is</span> <span class="keyword">not</span> self.nil) <span class="keyword">and</span> (key != x.key):</span><br><span class="line">            <span class="keyword">if</span> key &lt; x.key:</span><br><span class="line">                x = x.left</span><br><span class="line">            <span class="keyword">else</span>:</span><br><span class="line">                x = x.right</span><br><span class="line">        <span class="keyword">return</span> x</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">insert</span><span class="params">(self, z)</span>:</span></span><br><span class="line">        <span class="string">"insert z node with key and value"</span></span><br><span class="line">        y = self.nil</span><br><span class="line">        x = self.root</span><br><span class="line">        <span class="keyword">while</span> x <span class="keyword">is</span> <span class="keyword">not</span> self.nil:</span><br><span class="line">            y = x</span><br><span class="line">            <span class="keyword">if</span> z.key &lt; x.key:</span><br><span class="line">                x = x.left</span><br><span class="line">            <span class="keyword">else</span>:</span><br><span class="line">                x = x.right</span><br><span class="line">        z.p = y</span><br><span class="line">        <span class="keyword">if</span> y <span class="keyword">is</span> self.nil:</span><br><span class="line">            self.root = z</span><br><span class="line">        <span class="keyword">elif</span> z.key &lt; y.key:</span><br><span class="line">            y.left = z</span><br><span class="line">        <span class="keyword">else</span>:</span><br><span class="line">            y.right = z</span><br><span class="line">        z.left = self.nil</span><br><span class="line">        z.right = self.nil</span><br><span class="line">        z.color = RED</span><br><span class="line">        self.insert_fixup(z)</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">delete</span><span class="params">(self, z)</span>:</span></span><br><span class="line">        y = z</span><br><span class="line">        y_original_color = y.color</span><br><span class="line">        <span class="keyword">if</span> z.left <span class="keyword">is</span> self.nil:</span><br><span class="line">            x = z.right</span><br><span class="line">            self.transplant(z, x)</span><br><span class="line">        <span class="keyword">elif</span> z.right <span class="keyword">is</span> self.nil:</span><br><span class="line">            x = z.left</span><br><span class="line">            self.transplant(z, x)</span><br><span class="line">        <span class="keyword">else</span>:</span><br><span class="line">            y = self.minimum(z.right)</span><br><span class="line">            y_original_color = y.color</span><br><span class="line">            x = y.right</span><br><span class="line">            <span class="keyword">if</span> y.p <span class="keyword">is</span> z:</span><br><span class="line">                x.p = y</span><br><span class="line">            <span class="keyword">else</span>:</span><br><span class="line">                self.transplant(y, x)</span><br><span class="line">                y.right = z.right</span><br><span class="line">                y.right.p = y</span><br><span class="line">            self.transplant(z, y)</span><br><span class="line">            y.left = z.left</span><br><span class="line">            y.left.p = y</span><br><span class="line">            y.color = z.color</span><br><span class="line">        <span class="keyword">if</span> y_original_color <span class="keyword">is</span> BLACK:</span><br><span class="line">            self.delete_fixup(x)</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">is_empty</span><span class="params">(self)</span>:</span></span><br><span class="line">        <span class="keyword">return</span> self.root <span class="keyword">is</span> self.nil</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">right_walk</span><span class="params">(self, x=False)</span>:</span></span><br><span class="line">        <span class="keyword">if</span> x <span class="keyword">is</span> <span class="literal">False</span>:</span><br><span class="line">            x = self.root</span><br><span class="line">        <span class="keyword">if</span> x <span class="keyword">is</span> <span class="keyword">not</span> self.nil:</span><br><span class="line">            <span class="keyword">yield</span> <span class="keyword">from</span> self.right_walk(x.right)</span><br><span class="line">            <span class="keyword">yield</span> x</span><br><span class="line">            <span class="keyword">yield</span> <span class="keyword">from</span> self.right_walk(x.left)</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">left_walk</span><span class="params">(self, x=False)</span>:</span></span><br><span class="line">        <span class="keyword">if</span> x <span class="keyword">is</span> <span class="literal">False</span>:</span><br><span class="line">            x = self.root</span><br><span class="line">        <span class="keyword">if</span> x <span class="keyword">is</span> <span class="keyword">not</span> self.nil:</span><br><span class="line">            <span class="keyword">yield</span> <span class="keyword">from</span> self.left_walk(x.left)</span><br><span class="line">            <span class="keyword">yield</span> x</span><br><span class="line">            <span class="keyword">yield</span> <span class="keyword">from</span> self.left_walk(x.right)</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">force_search</span><span class="params">(self,key)</span>:</span></span><br><span class="line">        y = self.nil</span><br><span class="line">        x = self.root</span><br><span class="line">        <span class="keyword">while</span> x <span class="keyword">is</span> <span class="keyword">not</span> self.nil:</span><br><span class="line">            <span class="keyword">if</span> key == x.key:</span><br><span class="line">                <span class="keyword">return</span> x</span><br><span class="line">            y = x</span><br><span class="line">            <span class="keyword">if</span> key &lt; x.key:</span><br><span class="line">                x = x.left</span><br><span class="line">            <span class="keyword">else</span>:</span><br><span class="line">                x = x.right</span><br><span class="line">        z = rbnode()</span><br><span class="line">        original_z = z</span><br><span class="line">        z.key = key</span><br><span class="line">        z.value = self.default_value</span><br><span class="line">        z.p = y</span><br><span class="line">        <span class="keyword">if</span> y <span class="keyword">is</span> self.nil:</span><br><span class="line">            self.root = z</span><br><span class="line">        <span class="keyword">elif</span> z.key &lt; y.key:</span><br><span class="line">            y.left = z</span><br><span class="line">        <span class="keyword">else</span>:</span><br><span class="line">            y.right = z</span><br><span class="line">        z.left = self.nil</span><br><span class="line">        z.right = self.nil</span><br><span class="line">        z.color = RED</span><br><span class="line">        self.insert_fixup(z)</span><br><span class="line">        <span class="keyword">return</span> original_z</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">maximum</span><span class="params">(self, x=False)</span>:</span></span><br><span class="line">        <span class="keyword">if</span> x <span class="keyword">is</span> <span class="literal">False</span>:</span><br><span class="line">            x = self.root</span><br><span class="line">        <span class="keyword">while</span> x.right <span class="keyword">is</span> <span class="keyword">not</span> self.nil:</span><br><span class="line">            x = x.right</span><br><span class="line">        <span class="keyword">return</span> x</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">minimum</span><span class="params">(self, x=False)</span>:</span></span><br><span class="line">        <span class="keyword">if</span> x <span class="keyword">is</span> <span class="literal">False</span>:</span><br><span class="line">            x = self.root</span><br><span class="line">        <span class="keyword">while</span> x.left <span class="keyword">is</span> <span class="keyword">not</span> self.nil:</span><br><span class="line">            x = x.left</span><br><span class="line">        <span class="keyword">return</span> x</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">successor</span><span class="params">(self, x)</span>:</span></span><br><span class="line">        <span class="string">"return node with smallest key greater than x.key"</span></span><br><span class="line">        <span class="keyword">if</span> x.right <span class="keyword">is</span> <span class="keyword">not</span> self.nil:</span><br><span class="line">            <span class="keyword">return</span> self.minimum(x.right)</span><br><span class="line">        y = x.p</span><br><span class="line">        <span class="keyword">while</span> (y <span class="keyword">is</span> <span class="keyword">not</span> self.nil) <span class="keyword">and</span> (x <span class="keyword">is</span> y.right):</span><br><span class="line">            x = y</span><br><span class="line">            y = y.p</span><br><span class="line">        <span class="keyword">return</span> y</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">predecessor</span><span class="params">(self, x)</span>:</span></span><br><span class="line">        <span class="string">"return node with biggest key lower than x.key"</span></span><br><span class="line">        <span class="keyword">if</span> x.left <span class="keyword">is</span> <span class="keyword">not</span> self.nil:</span><br><span class="line">            <span class="keyword">return</span> self.maximum(x.left)</span><br><span class="line">        y = x.p</span><br><span class="line">        <span class="keyword">while</span> (y <span class="keyword">is</span> <span class="keyword">not</span> self.nil) <span class="keyword">and</span> (x <span class="keyword">is</span> y.left):</span><br><span class="line">            x = y</span><br><span class="line">            y = y.p</span><br><span class="line">        <span class="keyword">return</span> y</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">left_rotate</span><span class="params">(self, x)</span>:</span></span><br><span class="line">        y = x.right</span><br><span class="line">        x.right = y.left</span><br><span class="line">        <span class="keyword">if</span> y.left <span class="keyword">is</span> <span class="keyword">not</span> self.nil:</span><br><span class="line">            y.left.p = x</span><br><span class="line">        y.p = x.p</span><br><span class="line">        <span class="keyword">if</span> x.p <span class="keyword">is</span> self.nil:</span><br><span class="line">            self.root = y</span><br><span class="line">        <span class="keyword">else</span>:</span><br><span class="line">            <span class="keyword">if</span> x <span class="keyword">is</span> x.p.left:</span><br><span class="line">                x.p.left = y</span><br><span class="line">            <span class="keyword">else</span>:</span><br><span class="line">                x.p.right = y</span><br><span class="line">        y.left = x</span><br><span class="line">        x.p = y</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">right_rotate</span><span class="params">(self, x)</span>:</span></span><br><span class="line">        y = x.left</span><br><span class="line">        x.left = y.right</span><br><span class="line">        <span class="keyword">if</span> y.right <span class="keyword">is</span> <span class="keyword">not</span> self.nil:</span><br><span class="line">            y.right.p = x</span><br><span class="line">        y.p = x.p</span><br><span class="line">        <span class="keyword">if</span> x.p <span class="keyword">is</span> self.nil:</span><br><span class="line">            self.root = y</span><br><span class="line">        <span class="keyword">else</span>:</span><br><span class="line">            <span class="keyword">if</span> x <span class="keyword">is</span> x.p.right:</span><br><span class="line">                x.p.right = y</span><br><span class="line">            <span class="keyword">else</span>:</span><br><span class="line">                x.p.left = y</span><br><span class="line">        y.right = x</span><br><span class="line">        x.p = y</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">insert_fixup</span><span class="params">(self, z)</span>:</span></span><br><span class="line">        <span class="keyword">while</span> z.p.color <span class="keyword">is</span> RED:</span><br><span class="line">            <span class="keyword">if</span> z.p <span class="keyword">is</span> z.p.p.left:</span><br><span class="line">                y = z.p.p.right</span><br><span class="line">                <span class="keyword">if</span> y.color <span class="keyword">is</span> RED:</span><br><span class="line">                    z.p.color = BLACK</span><br><span class="line">                    y.color = BLACK</span><br><span class="line">                    z.p.p.color = RED</span><br><span class="line">                    z = z.p.p</span><br><span class="line">                <span class="keyword">else</span>:</span><br><span class="line">                    <span class="keyword">if</span> z <span class="keyword">is</span> z.p.right:</span><br><span class="line">                        z = z.p</span><br><span class="line">                        self.left_rotate(z)</span><br><span class="line">                    z.p.color = BLACK</span><br><span class="line">                    z.p.p.color = RED</span><br><span class="line">                    self.right_rotate(z.p.p)</span><br><span class="line">            <span class="keyword">else</span>:</span><br><span class="line">                y = z.p.p.left</span><br><span class="line">                <span class="keyword">if</span> y.color <span class="keyword">is</span> RED:</span><br><span class="line">                    z.p.color = BLACK</span><br><span class="line">                    y.color = BLACK</span><br><span class="line">                    z.p.p.color = RED</span><br><span class="line">                    z = z.p.p</span><br><span class="line">                <span class="keyword">else</span>:</span><br><span class="line">                    <span class="keyword">if</span> z <span class="keyword">is</span> z.p.left:</span><br><span class="line">                        z = z.p</span><br><span class="line">                        self.right_rotate(z)</span><br><span class="line">                    z.p.color = BLACK</span><br><span class="line">                    z.p.p.color = RED</span><br><span class="line">                    self.left_rotate(z.p.p)</span><br><span class="line">        self.root.color = BLACK</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">delete_fixup</span><span class="params">(self, x)</span>:</span></span><br><span class="line">        <span class="keyword">while</span> (x <span class="keyword">is</span> <span class="keyword">not</span> self.root) <span class="keyword">and</span> (x.color <span class="keyword">is</span> BLACK):</span><br><span class="line">            <span class="keyword">if</span> x <span class="keyword">is</span> x.p.left:</span><br><span class="line">                w = x.p.right</span><br><span class="line">                <span class="keyword">if</span> w.color <span class="keyword">is</span> RED:</span><br><span class="line">                    w.color = BLACK</span><br><span class="line">                    x.p.color = RED</span><br><span class="line">                    self.left_rotate(x.p)</span><br><span class="line">                    w = x.p.right</span><br><span class="line">                <span class="keyword">if</span> (w.left.color <span class="keyword">is</span> BLACK) <span class="keyword">and</span> (w.right.color <span class="keyword">is</span> BLACK):</span><br><span class="line">                    w.color = RED</span><br><span class="line">                    x = x.p</span><br><span class="line">                <span class="keyword">else</span>:</span><br><span class="line">                    <span class="keyword">if</span> w.right.color <span class="keyword">is</span> BLACK:</span><br><span class="line">                        w.left.color = BLACK</span><br><span class="line">                        w.color = RED</span><br><span class="line">                        self.right_rotate(w)</span><br><span class="line">                        w = x.p.right</span><br><span class="line">                    w.color = x.p.color</span><br><span class="line">                    x.p.color = BLACK</span><br><span class="line">                    w.right.color = BLACK</span><br><span class="line">                    self.left_rotate(x.p)</span><br><span class="line">                    x = self.root</span><br><span class="line">            <span class="keyword">else</span>:</span><br><span class="line">                w = x.p.left</span><br><span class="line">                <span class="keyword">if</span> w.color <span class="keyword">is</span> RED:</span><br><span class="line">                    w.color = BLACK</span><br><span class="line">                    x.p.color = RED</span><br><span class="line">                    self.right_rotate(x.p)</span><br><span class="line">                    w = x.p.left</span><br><span class="line">                <span class="keyword">if</span> (w.right.color <span class="keyword">is</span> BLACK) <span class="keyword">and</span> (w.left.color <span class="keyword">is</span> BLACK):</span><br><span class="line">                    w.color = RED</span><br><span class="line">                    x = x.p</span><br><span class="line">                <span class="keyword">else</span>:</span><br><span class="line">                    <span class="keyword">if</span> w.left.color <span class="keyword">is</span> BLACK:</span><br><span class="line">                        w.right.color = BLACK</span><br><span class="line">                        w.color = RED</span><br><span class="line">                        self.left_rotate(w)</span><br><span class="line">                        w = x.p.left</span><br><span class="line">                    w.color = x.p.color</span><br><span class="line">                    x.p.color = BLACK</span><br><span class="line">                    w.left.color = BLACK</span><br><span class="line">                    self.right_rotate(x.p)</span><br><span class="line">                    x = self.root</span><br><span class="line">        x.color = BLACK</span><br><span class="line"></span><br><span class="line">    <span class="function"><span class="keyword">def</span> <span class="title">transplant</span><span class="params">(self, u, v)</span>:</span></span><br><span class="line">        <span class="keyword">if</span> u.p <span class="keyword">is</span> self.nil:</span><br><span class="line">            self.root = v</span><br><span class="line">        <span class="keyword">elif</span> u <span class="keyword">is</span> u.p.left:</span><br><span class="line">            u.p.left = v</span><br><span class="line">        <span class="keyword">else</span>:</span><br><span class="line">            u.p.right = v</span><br><span class="line">        v.p = u.p</span><br></pre></td></tr></table></figure>
<p>这段红黑树的果子为rbnode对象，整个树根据果子的key构建，果子的value可以可以放我们字符串的字符。<br>默认的红黑树时通过不断加入节点自动生成的，但是加入果子的顺序不同会造成树以及果子的颜色的不同，可以看到我对标准的红黑树构造函数做了修改，这样我们可以根据给出的图片（1.jpg）构造一个红黑树。</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">if</span> __name__ == <span class="string">'__main__'</span>:</span><br><span class="line">	<span class="comment">#提示2，果子的value</span></span><br><span class="line">    _str=<span class="string">" ek`~3c:gf017b744/b38fd~abm7g5489e2&#123;lf6z8d16hae`98&#125;b|-21m.e:"</span></span><br><span class="line"></span><br><span class="line">    nodes=[_NONE]</span><br><span class="line">    <span class="keyword">for</span> i <span class="keyword">in</span> range(<span class="number">1</span>,<span class="number">60</span>):</span><br><span class="line">        nodes.append( rbnode(key=i,value=_str[i]) )</span><br><span class="line">        <span class="comment"># node, color, l,r,p</span></span><br><span class="line">    <span class="comment"># 录入图片红黑树的信息</span></span><br><span class="line">    tree=[</span><br><span class="line">            [<span class="number">1</span>,BLACK,<span class="number">0</span>,<span class="number">2</span>,<span class="number">3</span>],</span><br><span class="line">            [<span class="number">2</span>,RED,<span class="number">0</span>,<span class="number">0</span>,<span class="number">1</span>],</span><br><span class="line">            [<span class="number">3</span>,RED,<span class="number">1</span>,<span class="number">4</span>,<span class="number">6</span>],</span><br><span class="line">            [<span class="number">4</span>,BLACK,<span class="number">0</span>,<span class="number">5</span>,<span class="number">3</span>],</span><br><span class="line">            [<span class="number">5</span>,RED,<span class="number">0</span>,<span class="number">0</span>,<span class="number">4</span>],</span><br><span class="line">            [<span class="number">6</span>,BLACK,<span class="number">3</span>,<span class="number">8</span>,<span class="number">10</span>],</span><br><span class="line">            [<span class="number">7</span>,RED,<span class="number">0</span>,<span class="number">0</span>,<span class="number">8</span>],</span><br><span class="line">            [<span class="number">8</span>,BLACK,<span class="number">7</span>,<span class="number">9</span>,<span class="number">6</span>],</span><br><span class="line">            [<span class="number">9</span>,RED,<span class="number">0</span>,<span class="number">0</span>,<span class="number">8</span>],</span><br><span class="line">            [<span class="number">10</span>,RED,<span class="number">6</span>,<span class="number">18</span>,<span class="number">23</span>],</span><br><span class="line">            [<span class="number">11</span>,RED,<span class="number">0</span>,<span class="number">0</span>,<span class="number">12</span>],</span><br><span class="line">            [<span class="number">12</span>,BLACK,<span class="number">11</span>,<span class="number">13</span>,<span class="number">14</span>],</span><br><span class="line">            [<span class="number">13</span>,RED,<span class="number">0</span>,<span class="number">0</span>,<span class="number">12</span>],</span><br><span class="line">            [<span class="number">14</span>,RED,<span class="number">12</span>,<span class="number">16</span>,<span class="number">18</span>],</span><br><span class="line">            [<span class="number">15</span>,RED,<span class="number">0</span>,<span class="number">0</span>,<span class="number">16</span>],</span><br><span class="line">            [<span class="number">16</span>,BLACK,<span class="number">15</span>,<span class="number">17</span>,<span class="number">14</span>],</span><br><span class="line">            [<span class="number">17</span>,RED,<span class="number">0</span>,<span class="number">0</span>,<span class="number">16</span>],</span><br><span class="line">            [<span class="number">18</span>,BLACK,<span class="number">14</span>,<span class="number">20</span>,<span class="number">10</span>],</span><br><span class="line">            [<span class="number">19</span>,BLACK,<span class="number">0</span>,<span class="number">0</span>,<span class="number">20</span>],</span><br><span class="line">            [<span class="number">20</span>,RED,<span class="number">19</span>,<span class="number">21</span>,<span class="number">18</span>],</span><br><span class="line">            [<span class="number">21</span>,BLACK,<span class="number">0</span>,<span class="number">22</span>,<span class="number">20</span>],</span><br><span class="line">            [<span class="number">22</span>,RED,<span class="number">0</span>,<span class="number">0</span>,<span class="number">21</span>],</span><br><span class="line">            [<span class="number">23</span>,BLACK,<span class="number">10</span>,<span class="number">26</span>,<span class="number">28</span>],</span><br><span class="line">            [<span class="number">24</span>,RED,<span class="number">0</span>,<span class="number">0</span>,<span class="number">25</span>],</span><br><span class="line">            [<span class="number">25</span>,BLACK,<span class="number">24</span>,<span class="number">0</span>,<span class="number">26</span>],</span><br><span class="line">            [<span class="number">26</span>,BLACK,<span class="number">25</span>,<span class="number">27</span>,<span class="number">23</span>],</span><br><span class="line">            [<span class="number">27</span>,BLACK,<span class="number">0</span>,<span class="number">0</span>,<span class="number">26</span>],</span><br><span class="line">            [<span class="number">28</span>,BLACK,<span class="number">23</span>,<span class="number">43</span>,<span class="number">0</span>],</span><br><span class="line">            [<span class="number">29</span>,RED,<span class="number">0</span>,<span class="number">0</span>,<span class="number">30</span>],</span><br><span class="line">            [<span class="number">30</span>,BLACK,<span class="number">29</span>,<span class="number">31</span>,<span class="number">32</span>],</span><br><span class="line">            [<span class="number">31</span>,RED,<span class="number">0</span>,<span class="number">0</span>,<span class="number">30</span>],</span><br><span class="line">            [<span class="number">32</span>,BLACK,<span class="number">30</span>,<span class="number">34</span>,<span class="number">35</span>],</span><br><span class="line">            [<span class="number">33</span>,RED,<span class="number">0</span>,<span class="number">0</span>,<span class="number">34</span>],</span><br><span class="line">            [<span class="number">34</span>,BLACK,<span class="number">33</span>,<span class="number">0</span>,<span class="number">32</span>],</span><br><span class="line">            [<span class="number">35</span>,RED,<span class="number">32</span>,<span class="number">37</span>,<span class="number">43</span>],</span><br><span class="line">            [<span class="number">36</span>,BLACK,<span class="number">0</span>,<span class="number">0</span>,<span class="number">37</span>],</span><br><span class="line">            [<span class="number">37</span>,BLACK,<span class="number">36</span>,<span class="number">40</span>,<span class="number">35</span>],</span><br><span class="line">            [<span class="number">38</span>,BLACK,<span class="number">0</span>,<span class="number">39</span>,<span class="number">40</span>],</span><br><span class="line">            [<span class="number">39</span>,RED,<span class="number">0</span>,<span class="number">0</span>,<span class="number">38</span>],</span><br><span class="line">            [<span class="number">40</span>,RED,<span class="number">38</span>,<span class="number">41</span>,<span class="number">37</span>],</span><br><span class="line">            [<span class="number">41</span>,BLACK,<span class="number">0</span>,<span class="number">42</span>,<span class="number">40</span>],</span><br><span class="line">            [<span class="number">42</span>,RED,<span class="number">0</span>,<span class="number">0</span>,<span class="number">41</span>],</span><br><span class="line">            [<span class="number">43</span>,BLACK,<span class="number">35</span>,<span class="number">53</span>,<span class="number">28</span>],</span><br><span class="line">            [<span class="number">44</span>,BLACK,<span class="number">0</span>,<span class="number">0</span>,<span class="number">45</span>],</span><br><span class="line">            [<span class="number">45</span>,RED,<span class="number">44</span>,<span class="number">46</span>,<span class="number">48</span>],</span><br><span class="line">            [<span class="number">46</span>,BLACK,<span class="number">0</span>,<span class="number">47</span>,<span class="number">45</span>],</span><br><span class="line">            [<span class="number">47</span>,RED,<span class="number">0</span>,<span class="number">0</span>,<span class="number">46</span>],</span><br><span class="line">            [<span class="number">48</span>,BLACK,<span class="number">45</span>,<span class="number">50</span>,<span class="number">53</span>],</span><br><span class="line">            [<span class="number">49</span>,BLACK,<span class="number">0</span>,<span class="number">0</span>,<span class="number">50</span>],</span><br><span class="line">            [<span class="number">50</span>,RED,<span class="number">49</span>,<span class="number">51</span>,<span class="number">48</span>],</span><br><span class="line">            [<span class="number">51</span>,BLACK,<span class="number">0</span>,<span class="number">52</span>,<span class="number">50</span>],</span><br><span class="line">            [<span class="number">52</span>,RED,<span class="number">0</span>,<span class="number">0</span>,<span class="number">51</span>],</span><br><span class="line">            [<span class="number">53</span>,RED,<span class="number">48</span>,<span class="number">57</span>,<span class="number">43</span>],</span><br><span class="line">            [<span class="number">54</span>,RED,<span class="number">0</span>,<span class="number">0</span>,<span class="number">55</span>],</span><br><span class="line">            [<span class="number">55</span>,BLACK,<span class="number">54</span>,<span class="number">56</span>,<span class="number">57</span>],</span><br><span class="line">            [<span class="number">56</span>,RED,<span class="number">0</span>,<span class="number">0</span>,<span class="number">55</span>],</span><br><span class="line">            [<span class="number">57</span>,BLACK,<span class="number">55</span>,<span class="number">59</span>,<span class="number">53</span>],</span><br><span class="line">            [<span class="number">58</span>,RED,<span class="number">0</span>,<span class="number">0</span>,<span class="number">59</span>],</span><br><span class="line">            [<span class="number">59</span>,BLACK,<span class="number">58</span>,<span class="number">0</span>,<span class="number">57</span>],</span><br><span class="line">            ]</span><br><span class="line">    <span class="keyword">for</span> i <span class="keyword">in</span> range(len(tree)):</span><br><span class="line">        nodes[tree[i][<span class="number">0</span>]].color=tree[i][<span class="number">1</span>]</span><br><span class="line">        nodes[tree[i][<span class="number">0</span>]].left=nodes[tree[i][<span class="number">2</span>]]</span><br><span class="line">        nodes[tree[i][<span class="number">0</span>]].right=nodes[tree[i][<span class="number">3</span>]]</span><br><span class="line">        nodes[tree[i][<span class="number">0</span>]].p=nodes[tree[i][<span class="number">4</span>]]</span><br><span class="line">    <span class="comment"># 打印二叉树</span></span><br><span class="line">    tr=rbtree(nodes=nodes)</span><br><span class="line">    print(tr)</span><br></pre></td></tr></table></figure>
<p><strong>备注：</strong></p>
<p>这真的是一个红黑树的一个很好的实现，还可以可视化的打印整棵树，这里给出正常的构造树的方法，只需给出果子的key和value：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">if</span> __name__ == <span class="string">'__main__'</span>:</span><br><span class="line">    tr=rbtree(data=&#123;<span class="string">'1'</span>:<span class="string">'1'</span>,<span class="string">'2'</span>:<span class="string">'2'</span>&#125;.items())</span><br><span class="line">    print(tr)</span><br></pre></td></tr></table></figure>
<h2 id="0x03"><a href="#0x03" class="headerlink" title="0x03"></a>0x03</h2><p>根据提示3，从树上取走第 18,35,53,50,14,28,19,6,54,36 个果子：</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">for</span> i <span class="keyword">in</span> [<span class="number">18</span>,<span class="number">35</span>,<span class="number">53</span>,<span class="number">50</span>,<span class="number">14</span>,<span class="number">28</span>,<span class="number">19</span>,<span class="number">6</span>,<span class="number">54</span>,<span class="number">36</span>]:</span><br><span class="line">    tr.delete(tr.force_search(i))</span><br></pre></td></tr></table></figure>
<h2 id="0x04"><a href="#0x04" class="headerlink" title="0x04"></a>0x04</h2><p>根据提示4和5，获取第[8,56,47,37,52,34,17,8,8,29,7,47,40,57,46,24,34,34,57,29,22,5,16,57,24,29,8,12,57,12,12,21,33,34,55,51,22,45,34,31,1,23]果子的值，并且按照颜色对其ascii+1或-1，即可得到flag</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">s=<span class="string">""</span></span><br><span class="line"><span class="keyword">for</span> i <span class="keyword">in</span> [<span class="number">8</span>,<span class="number">56</span>,<span class="number">47</span>,<span class="number">37</span>,<span class="number">52</span>,<span class="number">34</span>,<span class="number">17</span>,<span class="number">8</span>,<span class="number">8</span>,<span class="number">29</span>,<span class="number">7</span>,<span class="number">47</span>,<span class="number">40</span>,<span class="number">57</span>,<span class="number">46</span>,<span class="number">24</span>,<span class="number">34</span>,<span class="number">34</span>,<span class="number">57</span>,<span class="number">29</span>,<span class="number">22</span>,<span class="number">5</span>,<span class="number">16</span>,<span class="number">57</span>,<span class="number">24</span>,<span class="number">29</span>,<span class="number">8</span>,<span class="number">12</span>,<span class="number">57</span>,<span class="number">12</span>,<span class="number">12</span>,<span class="number">21</span>,<span class="number">33</span>,<span class="number">34</span>,<span class="number">55</span>,<span class="number">51</span>,<span class="number">22</span>,<span class="number">45</span>,<span class="number">34</span>,<span class="number">31</span>,<span class="number">1</span>,<span class="number">23</span>]:</span><br><span class="line">    node=tr.force_search(i)</span><br><span class="line">    <span class="keyword">if</span> node.color==BLACK:</span><br><span class="line">        s+=chr(ord(node.value)<span class="number">-1</span>)</span><br><span class="line">    <span class="keyword">else</span>:</span><br><span class="line">        s+=chr(ord(node.value)+<span class="number">1</span>)</span><br><span class="line">print(s)</span><br></pre></td></tr></table></figure>
<p>算出flag为：<br>flag{10ff49a7-db11-4e43-b4f6-66ef12ceb19d}</p>
<h1 id="martricks"><a href="#martricks" class="headerlink" title="martricks"></a>martricks</h1><p>刚拿到这题就感觉跟符号执行有关系，可惜没有贯彻思想继续做下去，不过解法蛮简单的，这里简单记录一下，也是当学习一下angr吧：</p>
<h2 id="0x01-1"><a href="#0x01-1" class="headerlink" title="0x01"></a>0x01</h2><p>拿到题目ida打开，大概F5看一下，有一个判断，如果等于0就congrats否则wrong，那么记下这两处字符串的地址。</p>
<p><img src="/ctf-2018网鼎杯二叉树-martrickswp/1535025943800.png" alt="1535025943800"></p>
<h2 id="0x02-1"><a href="#0x02-1" class="headerlink" title="0x02"></a>0x02</h2><p>接下来就可以用angr调用该文件，根据符号执行让我们执行到400A84地址，其中避免经过400A90地址</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> angr</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">def</span> <span class="title">angr_example</span><span class="params">()</span>:</span></span><br><span class="line">    p = angr.Project(<span class="string">"./martricks"</span>)</span><br><span class="line">    simgr = p.factory.simulation_manager(p.factory.full_init_state())</span><br><span class="line">    simgr.explore(find=<span class="number">0x400A84</span>, avoid=<span class="number">0x400A90</span>)  <span class="comment"># 成功路径，失败路径</span></span><br><span class="line"></span><br><span class="line">    <span class="keyword">return</span> simgr.found[<span class="number">0</span>].posix.dumps(<span class="number">0</span>).strip(<span class="string">'\0\n'</span>)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="keyword">if</span> __name__ == <span class="string">'__main__'</span>:</span><br><span class="line">    <span class="keyword">print</span> angr_example()</span><br></pre></td></tr></table></figure>
<p>等待一会后得到flag：</p>
<p>flag{Everyth1n_th4t_kill5_m3_m4kes_m3_fee1_aliv3}</p>
<p><strong>注：</strong> 所有程序题目已经上传至GitHub：<a href="https://github.com/Anemone95/ctf_wp/tree/master/wangding2018" target="_blank" rel="noopener">https://github.com/Anemone95/ctf_wp/tree/master/wangding2018</a></p>

    </div>

    
    
    
        
      
        

<div>
<ul class="post-copyright">
  <li class="post-copyright-author">
    <strong>本文作者： </strong>Anemone</li>
  <li class="post-copyright-link">
    <strong>本文链接：</strong>
    <a href="http://anemone.top/ctf-2018网鼎杯二叉树-martrickswp/" title="2018网鼎杯二叉树&martricks wp">http://anemone.top/ctf-2018网鼎杯二叉树-martrickswp/</a>
  </li>
  <li class="post-copyright-license">
    <strong>版权声明： </strong>本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh" rel="noopener" target="_blank"><i class="fa fa-fw fa-creative-commons"></i>BY-NC-SA</a> 许可协议。转载请注明出处！</li>
</ul>
</div>

      

      <footer class="post-footer">
          
            
          
          <div class="post-tags">
            
              <a href="/tags/CTF/" rel="tag"># CTF</a>
            
              <a href="/tags/二叉树/" rel="tag"># 二叉树</a>
            
              <a href="/tags/符号执行/" rel="tag"># 符号执行</a>
            
              <a href="/tags/angr/" rel="tag"># angr</a>
            
          </div>
        

        

          <div class="post-nav">
            <div class="post-nav-next post-nav-item">
              
                <a href="/ctf-i春秋巅峰极客CTF-A-Simple-CMS-loli-WP/" rel="next" title="i春秋 “巅峰极客” CTF A Simple CMS&loli WP">
                  <i class="fa fa-chevron-left"></i> i春秋 “巅峰极客” CTF A Simple CMS&loli WP
                </a>
              
            </div>

            <span class="post-nav-divider"></span>

            <div class="post-nav-prev post-nav-item">
              
                <a href="/blockchain-智能合约checklist/" rel="prev" title="智能合约Checklist">
                  智能合约Checklist <i class="fa fa-chevron-right"></i>
                </a>
              
            </div>
          </div>
        
      </footer>
    
  </div>
  
  
  
  </article>

  </div>


          </div>
          
    
    <div class="comments" id="gitalk-container"></div>
  

        </div>
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">
        
        
        
        
      

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#二叉树"><span class="nav-number">1.</span> <span class="nav-text">二叉树</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#0x01"><span class="nav-number">1.1.</span> <span class="nav-text">0x01</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#0x02"><span class="nav-number">1.2.</span> <span class="nav-text">0x02</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#0x03"><span class="nav-number">1.3.</span> <span class="nav-text">0x03</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#0x04"><span class="nav-number">1.4.</span> <span class="nav-text">0x04</span></a></li></ol></li><li class="nav-item nav-level-1"><a class="nav-link" href="#martricks"><span class="nav-number">2.</span> <span class="nav-text">martricks</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#0x01-1"><span class="nav-number">2.1.</span> <span class="nav-text">0x01</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#0x02-1"><span class="nav-number">2.2.</span> <span class="nav-text">0x02</span></a></li></ol></li></ol></div>
        
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image"
      src="/images/avatar.jpg"
      alt="Anemone">
  <p class="site-author-name" itemprop="name">Anemone</p>
  <div class="site-description" itemprop="description">关注Web安全、移动安全、Fuzz测试和机器学习</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
        
          <a href="/archives/">
        
          <span class="site-state-item-count">70</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
    
      
      
      <div class="site-state-item site-state-categories">
        
          
            <a href="/categories/">
          
        
        <span class="site-state-item-count">31</span>
        <span class="site-state-item-name">分类</span>
        </a>
      </div>
    
      
      
      <div class="site-state-item site-state-tags">
        
          
            <a href="/tags/">
          
        
        <span class="site-state-item-count">86</span>
        <span class="site-state-item-name">标签</span>
        </a>
      </div>
    
  </nav>
</div>
  <div class="feed-link motion-element">
    <a href="/atom.xml" rel="alternate">
      <i class="fa fa-rss"></i>RSS
    </a>
  </div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="https://github.com/anemone95" title="GitHub &rarr; https://github.com/anemone95" rel="noopener" target="_blank"><i class="fa fa-fw fa-github"></i>GitHub</a>
      </span>
    
      <span class="links-of-author-item">
      
      
        
      
      
        
      
        <a href="mailto:anemone95@qq.com" title="E-Mail &rarr; mailto:anemone95@qq.com" rel="noopener" target="_blank"><i class="fa fa-fw fa-envelope"></i>E-Mail</a>
      </span>
    
  </div>
  <div class="cc-license motion-element" itemprop="license">
    
  
    <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/deed.zh" class="cc-opacity" rel="noopener" target="_blank"><img src="/images/cc-by-nc-sa.svg" alt="Creative Commons"></a>
  </div>



      </div>

    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright">&copy; 2018 – <span itemprop="copyrightYear">2020</span>
  <span class="with-love" id="animate">
    <i class="fa fa-user"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">anemone</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io" class="theme-link" rel="noopener" target="_blank">Hexo</a> 强力驱动 v3.9.0</div>
  <span class="post-meta-divider">|</span>
  <div class="theme-info">主题 – <a href="https://theme-next.org" class="theme-link" rel="noopener" target="_blank">NexT.Pisces</a> v7.4.0</div>

        






  
  <script>
  function leancloudSelector(url) {
    return document.getElementById(url).querySelector('.leancloud-visitors-count');
  }
  if (CONFIG.page.isPost) {
    function addCount(Counter) {
      var visitors = document.querySelector('.leancloud_visitors');
      var url = visitors.getAttribute('id').trim();
      var title = visitors.getAttribute('data-flag-title').trim();

      Counter('get', `/classes/Counter?where=${JSON.stringify({ url })}`)
        .then(response => response.json())
        .then(({ results }) => {
          if (results.length > 0) {
            var counter = results[0];
            Counter('put', '/classes/Counter/' + counter.objectId, { time: { '__op': 'Increment', 'amount': 1 } })
              .then(response => response.json())
              .then(() => {
                leancloudSelector(url).innerText = counter.time + 1;
              })
            
              .catch(error => {
                console.log('Failed to save visitor count', error);
              })
          } else {
              Counter('post', '/classes/Counter', { title: title, url: url, time: 1 })
                .then(response => response.json())
                .then(() => {
                  leancloudSelector(url).innerText = 1;
                })
                .catch(error => {
                  console.log('Failed to create', error);
                });
            
          }
        })
        .catch(error => {
          console.log('LeanCloud Counter Error', error);
        });
    }
  } else {
    function showTime(Counter) {
      var visitors = document.querySelectorAll('.leancloud_visitors');
      var entries = [...visitors].map(element => {
        return element.getAttribute('id').trim();
      });

      Counter('get', `/classes/Counter?where=${JSON.stringify({ url: { '$in': entries } })}`)
        .then(response => response.json())
        .then(({ results }) => {
          if (results.length === 0) {
            document.querySelectorAll('.leancloud_visitors .leancloud-visitors-count').forEach(element => {
              element.innerText = 0;
            });
            return;
          }
          for (var i = 0; i < results.length; i++) {
            var item = results[i];
            var url = item.url;
            var time = item.time;
            leancloudSelector(url).innerText = time;
          }
          for (var i = 0; i < entries.length; i++) {
            var url = entries[i];
            var element = leancloudSelector(url);
            if (element.innerText == '') {
              element.innerText = 0;
            }
          }
        })
        .catch(error => {
          console.log('LeanCloud Counter Error', error);
        });
    }
  }

  fetch('https://app-router.leancloud.cn/2/route?appId=o5UaCJdPfEG0g7MVxXSMagpT-gzGzoHsz')
    .then(response => response.json())
    .then(({ api_server }) => {
      var Counter = (method, url, data) => {
        return fetch(`https://${api_server}/1.1${url}`, {
          method: method,
          headers: {
            'X-LC-Id': 'o5UaCJdPfEG0g7MVxXSMagpT-gzGzoHsz',
            'X-LC-Key': 'c6IN1PuMV3QPltJcrHfn74Gt',
            'Content-Type': 'application/json',
          },
          body: JSON.stringify(data)
        });
      };
      if (CONFIG.page.isPost) {
        const localhost = /http:\/\/(localhost|127.0.0.1|0.0.0.0)/;
        if (localhost.test(document.URL)) return;
        addCount(Counter);
      } else if (document.querySelectorAll('.post-title-link').length >= 1) {
        showTime(Counter);
      }
    });
  </script>






        
      </div>
    </footer>
  </div>

  
  <script src="//cdn.jsdelivr.net/npm/animejs@3.1.0/lib/anime.min.js"></script>
  <script src="https://cdn.bootcss.com/velocity/1.2.1/velocity.min.js"></script>
  <script src="https://cdn.bootcss.com/velocity/1.2.1/velocity.ui.js"></script>
<script src="/js/utils.js?v=7.4.0"></script><script src="/js/motion.js?v=7.4.0"></script>
<script src="/js/schemes/pisces.js?v=7.4.0"></script>
<script src="/js/next-boot.js?v=7.4.0"></script>



  
  <script>
    (function(){
      var bp = document.createElement('script');
      var curProtocol = window.location.protocol.split(':')[0];
      bp.src = (curProtocol === 'https') ? 'https://zz.bdstatic.com/linksubmit/push.js' : 'http://push.zhanzhang.baidu.com/push.js';
      var s = document.getElementsByTagName("script")[0];
      s.parentNode.insertBefore(bp, s);
    })();
  </script>








  
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/instantsearch.js@2.10.4/dist/instantsearch.min.css">
<script src="//cdn.jsdelivr.net/npm/instantsearch.js@2.10.4/dist/instantsearch.min.js"></script><script src="/js/algolia-search.js?v=7.4.0"></script>











<script>
if (document.querySelectorAll('pre.mermaid').length) {
  NexT.utils.getScript('//cdn.bootcss.com/mermaid/8.2.6/mermaid.min.js', () => {
    mermaid.initialize({
      theme: 'forest',
      logLevel: 3,
      flowchart: { curve: 'linear' },
      gantt: { axisFormat: '%m/%d/%Y' },
      sequence: { actorMargin: 50 }
    });
  }, window.mermaid);
}
</script>




  

  

  

  

<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.css">

<script>
  NexT.utils.getScript('//cdn.jsdelivr.net/npm/gitalk@1/dist/gitalk.min.js', () => {
    var gitalk = new Gitalk({
      clientID: 'f3075553d7b0225df6ca',
      clientSecret: '68362ba87c4cc8e13103afcf729f5bd8ea176a78',
      repo: 'anemone95.github.io',
      owner: 'Anemone95',
      admin: ['Anemone95'],
      id: '2ff908a3ce3d6c4ff907b077b4a325c7',
        language: window.navigator.language || window.navigator.userLanguage,
      
      distractionFreeMode: 'true'
    });
    gitalk.render('gitalk-container');
  }, window.Gitalk);
</script>

</body>
</html>
